package com.bappi.utils;

import static android.provider.BaseColumns._ID;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {
	private static final String DATABASE_NAME = "database.db";
	private static final int DATABASE_VERSION = 1;
	
	public static final String TABLE_NAME_1 = "calories";
	public static final String TABLE_NAME_2 = "units";
	public static final String TABLE_NAME_3 = "activities";
	public static final String TABLE_NAME_4 = "weight";

	/** Create a helper object for the Events database */
	public DatabaseHelper(Context ctx) {
		super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE " + TABLE_NAME_1 + " (" + _ID
				+ " INTEGER PRIMARY KEY AUTOINCREMENT, time INTEGER, value  INTEGER );");
		db.execSQL("CREATE TABLE " + TABLE_NAME_2 + " (" + _ID
				+ " INTEGER PRIMARY KEY AUTOINCREMENT, time INTEGER, value  INTEGER );");
		db.execSQL("CREATE TABLE " + TABLE_NAME_3 + " (" + _ID
				+ " INTEGER PRIMARY KEY AUTOINCREMENT, time INTEGER, value  INTEGER );");
		db.execSQL("CREATE TABLE " + TABLE_NAME_4 + " (" + _ID
				+ " INTEGER PRIMARY KEY AUTOINCREMENT, time INTEGER, value  INTEGER );");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME_1);
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME_2);
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME_3);
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME_4);
		onCreate(db);
	}
}
